#! /usr/bin/env python
# -*- coding: UTF-8 -*-
#
# Copyright (c) 2008 jiakuan.net and widenhome.com, All rights reserved.
# 
# Created on 2008-12-2, by Jiakuan Wang.
#

"""
This script define the variables for i18n.
"""

import os
import gettext
import i18n_util
from javavatask.storage import getLanguage

basedir = os.path.dirname(__file__)

# The domain name of the i18n
domain = "javavatask"

# Define the locale path for the i18n, the relative path should be relative to 
# the main entry file of the python application.
localedir = "locale"

languages = ['en', 'zh_CN', 'zh_TW']

# Customize the parameters for specific project.
po_parameters = {"Project.Id.Version":"Javava 1.0",
              "Last.Translator":"Jiakuan Wang",
              "Last.Translator.Email":"delight.wjk@gmail.com",
              "Team.Name":"Widen",
              "Team.Email":"delight.wjk@gmail.com"}

def load_language_setting():
    return getLanguage()

def init_i18n():
    current_language = i18n_util.get_current_language(basedir, localedir, 
                                                      load_language_setting)
    print 'Current language is', current_language, '...'
    
    # Load the translate of the language
    t = gettext.translation(domain=domain, localedir=localedir, 
                            languages=[current_language])
    t.install(True)

if __name__ == '__main__':
    print load_language_setting()
    gen = i18n_util.Generator(basedir, domain, localedir, languages, po_parameters)
    gen.execute()
